import React, { useEffect, useState } from 'react';
import { connect } from 'umi';
function Dva(props) {
  const [data, setData] = useState([]);
  const [count, setCount] = useState({ a: 0 });
  useEffect(() => {
    console.log('props', props);
  }, [props.bao.tagList]);

  const getTags = () => {
    props.dispatch({
      type: 'bao/fetchTags', // model 的命名空间 / 方法
      payload: { name: '传递过来的参数' }, //  传递的参数，放到 post 里面的参数
    });
  };
  return (
    <div>
      Dva
      <button onClick={getTags}> 获取标签数据 </button>
      {props.bao.tagList.length &&
        props.bao.tagList.map((item, index) => (
          <div key={index}> {item.name} </div>
        ))}
      <div>count中 a 的数据是 {count.a} </div>
      <button> a ++ </button>
    </div>
  );
}

export default connect(({ bao }) => ({ bao }))(Dva);
